<template>
  <div class="!p-0">
    <BottomFixed>
      <PatientInfoPanel class="bg-white" :info="consultationInfo"/>

      <van-tabs v-model:active="activeTab" class="pb-1">
        <van-tab title="时间轴">
          <div class="tab-card">
            <Timeline :info="consultationInfo"/>
          </div>
        </van-tab>

        <van-tab title="会诊信息">
          <div class="tab-card">
            <ConsultationInfo :info="consultationInfo"/>
          </div>
        </van-tab>

        <van-tab title="病例摘要">
          <div class="tab-card">
            <CaseSummary :info="consultationInfo"/>
          </div>
        </van-tab>

        <van-tab title="检查检验">
          <div class="tab-card">
            <InspectionTesting :info="consultationInfo.attach"/>
          </div>
        </van-tab>

        <van-tab v-if="showReportTab" :title="reportTabTitle">
          <ConsultationReportList :info="consultationInfo"/>
        </van-tab>

        <van-tab title="会诊目的">
          <div class="tab-card">
            <ConsultationPurpose :info="consultationInfo"/>
          </div>
        </van-tab>
      </van-tabs>

      <template #bottom>
        <div :class="{ 'btn-box': useBtnBoxDefaultCss }">
          <slot></slot>
        </div>
      </template>
    </BottomFixed>
  </div>
</template>

<script lang="ts">
import {defineComponent} from "vue";
import BottomFixed from "./components/BottomFixed.vue";
import PatientInfoPanel from "./components/PatientInfoPanel.vue";
import Timeline from "./components/Timeline.vue";
import ConsultationInfo from "./components/ConsultationInfo.vue";
import CaseSummary from "./components/CaseSummary.vue";
import InspectionTesting from "./components/InspectionTesting.vue";
import ConsultationReportList from "./components/ConsultationReportList.vue";
import ConsultationPurpose from "./components/ConsultationPurpose.vue";
import ConsultationConstant from "./components/consultation-constant";

export default defineComponent({
  name: "ConsultationDetails",
  components: {
    BottomFixed,
    PatientInfoPanel,
    Timeline,
    ConsultationInfo,
    CaseSummary,
    InspectionTesting,
    ConsultationReportList,
    ConsultationPurpose,
  },
  props: {
    useBtnBoxDefaultCss: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      activeTab: "",
      consultationInfo: {},
    };
  },
  computed: {
    showReportTab() {
      const info = this.consultationInfo;
      if (
          info.approveStep === ConsultationConstant.approveStatus.consultation &&
          !info.apply
      ) {
        return true;
      }

      if (
          info.approveStep ===
          ConsultationConstant.approveStatus.reportQualityControl &&
          !info.apply
      ) {
        return true;
      }

      if (
          info.approveStep === ConsultationConstant.approveStatus.publish &&
          (!info.apply ||
              info.reportStatus === ConsultationConstant.reportStatus.publish)
      ) {
        return true;
      }

      return false;
    },
    reportTabTitle() {
      const info = this.consultationInfo;
      return info.approveStep ===
      ConsultationConstant.approveStatus.reportQualityControl
          ? "会诊意见"
          : "会诊报告";
    },
  },
  created() {
    this.consultationInfo = {
      "id": 1142,
      "roomId": null,
      "endDate": null,
      "serialNumber": "H20240130002",
      "consultationType": "clinical",
      "consultationTypeStr": "临床会诊",
      "consultationTypeStr02": "临床会诊<span><img style='width:20px;height:20px;margin:2px' title='交互式会诊' src='http://127.0.0.1:8781/V1_YCYL_SHRJ//static/admin/images/clinic.png'></span>",
      "consultationTypeAndWayStr": "临床会诊 / 专家会诊",
      "cosultationSourceType": "byl",
      "thirdSourceUUID": null,
      "thirdSourceName": null,
      "thirdApplyId": null,
      "thirdHospitalName": null,
      "thirdHospitalOrganizationName": null,
      "thirdHospitalSubOrganizationName": null,
      "applyInstitutionId": 536,
      "applyHospitalUUID": "8788aeb5-0496-4786-9f77-6cd1f551d77a",
      "applyHospitalName": "ls阜阳市人民医院",
      "applyInstitutionName": "ls阜阳市人民医院",
      "applyInstitutionPicUrl": "http://127.0.0.1:8781/V1_YCYL_SHRJ///static/defaultimages/hospitals/defaultPicUrl.jpg",
      "applyDepartmentId": null,
      "applyDepartmentName": null,
      "applyRoomId": null,
      "applyRoomName": null,
      "applyUserId": 1357,
      "applyUserName": "ls阜阳市人民医院会诊中心管理员/fyrm",
      "applyDate": "2024-01-30 13:48",
      "applyUserName2": "会诊中心管理员",
      "applyUserName3": "阜阳人民",
      "consultationWay": "expert",
      "consultationWayStr": "专家会诊",
      "serverInstiuttionId": 1,
      "serverInstiuttionUUID": "c71569f7-0495-4ddc-8f6c-b897db71f758",
      "serverInstiuttionName": "上海交通大学医学院附属仁济医院",
      "serverInstitutionPicUrl": null,
      "serverDepartments": [
        {
          "id": 2248,
          "consultationApplyId": 1142,
          "serverDepartmentId": 3,
          "serverDepartmentUUID": "9cc27e46-ee45-4704-9dc0-f198386d8b25",
          "serverDepartmentName": "外科",
          "serversubDepartmentId": 15,
          "serversubDepartmentUUID": "861e388a-1dd5-41cd-ac6d-f5da1f7d11f7",
          "serversubDepartmentName": "泌尿科",
          "serverUserId": null,
          "serverUserUUID": null,
          "serverUserName": null,
          "ensureServerDepartmentId": 3,
          "ensureServerDepartmentUUID": "9cc27e46-ee45-4704-9dc0-f198386d8b25",
          "ensureServerDepartmentName": "外科",
          "ensureServersubDepartmentId": 15,
          "ensureServersubDepartmentUUID": "861e388a-1dd5-41cd-ac6d-f5da1f7d11f7",
          "ensureServersubDepartmentName": "泌尿科",
          "ensureServerUserId": 656,
          "ensureServerUserUUID": "26e16b13-7459-4f6d-8968-9d08915d2586",
          "ensureServerUserName": "刘炜",
          "ensureServerUserPicUrl": "http://127.0.0.1:8781/V1_YCYL_SHRJ///static/JUI/images/profile.png",
          "ids": null,
          "ensureInstitutionDepartmentId": null,
          "ensureSubInstitutionDepartmentId": null,
          "doctorId": null,
          "serverInstitutionDepartmentId": null,
          "serverSubInstitutionDepartmentId": null,
          "serverDoctorId": null,
          "ensureAppointTime": null,
          "ensureDayRangeType": null,
          "ensureInstitutionConsulationRoomId": null,
          "serverUserPhone": null,
          "ensureServerUserPhone": "",
          "consultationScheduleRecordId": null,
          "mainDiagnosis": false,
          "mainDiagnosisId": null,
          "docTypeId": 351,
          "docTypeUUID": "65876019-dad9-4647-b216-7a5ad51fc0c3",
          "ensureConferenceMethodId": null,
          "ensureConferenceMethodName": null,
          "patientPhone": null,
          "uuid": "687af3c9-eb9a-4a17-911d-521322d06892"
        }
      ],
      "serverDepartmentIds": null,
      "serverUserIds": null,
      "serverInfo": "上海交通大学医学院附属仁济医院外科泌尿科",
      "ensureInfo": "外科/泌尿科",
      "ensureAppointTime": "2024-01-31 00:00",
      "ensureDayRangeType": null,
      "ensureDayRangeTypeStr": "",
      "ensureInstitutionConsulationRoomId": 4,
      "ensureInstitutionConsulationRoomName": "17号楼411",
      "ensureConferenceMethodId": 413,
      "ensureConferenceMethodCode": "03",
      "ensureConferenceMethodName": "索高和硬件",
      "ensureTimeAndAddress": "2024-01-31 00:00 17号楼411",
      "appointTime": "2024-01-31",
      "dayRangeType": null,
      "dayRangeTypeStr": "",
      "patient": null,
      "patientId": null,
      "patientUUID": "dbc1d5f1-5d0f-4696-92dd-80dd880803cf",
      "patientName": "栗建新",
      "patientIdTypeId": 334,
      "patientIdTypeName": "居民身份证",
      "patientIdNumber": "342128195402090016",
      "patientIdNumberStr": "342***********0016",
      "patientAge": "70",
      "patientAgeText": "70",
      "patientSex": "boy",
      "patientSexStr": "男",
      "patientMarriageId": null,
      "patientMarriageName": null,
      "patientConditionTypeId": null,
      "patientConditionTypeName": null,
      "patientWeight": 1,
      "patientHeight": 1,
      "patientCountryId": null,
      "patientCountryName": null,
      "patientNationId": null,
      "patientNationName": null,
      "patientBirthDay": "1954-02-09",
      "patientHealthCareTypeId": null,
      "patientHealthCareTypeName": null,
      "patientHealthCareNumber": "",
      "patientPhone": "133****0000",
      "patientOccupation": "",
      "patientAddress": "",
      "patientClinicDepartment": "",
      "patientVisitTypeId": null,
      "patientVisitTypeName": null,
      "patientInHospitalDate": null,
      "patientOutPateientNumber": "",
      "patientStayHospitialNumber": "",
      "patientPicUrl": null,
      "patientFromHIS": null,
      "currentMedicalHistory": "患者1月前无明显诱因下出现头晕、头懵不适，无视物旋转、恶心呕吐，无肢体麻木无力、舌根发硬、口齿不清，无头痛，无恶心、呕吐，无意识不清，无四肢抽搐，无饮水呛咳、吞咽困难等症状，当时未予以重视；10余天前患者感头晕加重，伴有行走不稳、发飘感，感全身乏力，余症状基本同前，后就诊阜阳中医院，完善头颅MR提示：左侧侧脑室后脚异常信号，考虑占位可能；左侧基底节区DWI高信号，考虑脑梗死。现拟“脑梗死？”收住我科。病程中，患者精神一般，饮食睡眠一般，大小便正常。",
      "pastHistory": "平素健康情况：一般；疾病史：糖尿病20余年，现规律应用胰岛素降糖治疗，具体不详；高血压5-6年，规律用药，具体不详。",
      "allergicHistory": "否认食物及药物过敏史。",
      "checkUp": "神清，语利，对答切题。双瞳孔等大等圆，直径约3mm,光反射敏感。眼睑无下垂，双眼球居中，诸方向运动充分，无复视及眼球震颤。双侧额纹对称存在，闭目有力，角膜反射存在。鼻唇沟对称，示齿口角无歪斜，伸舌居中，颈软，克布式征（-）。四肢肌力Ⅴ级，肌张力正常。双侧babinski征(-)。",
      "accessoryExam": "2023-12-18 头颅MR增强扫描1.5T 双侧大脑半球对称，灰白质分界清晰。双侧侧脑室旁见多发环形及肿块样稍长T1长T2信号，DWI呈高信号，其左侧侧脑室旁较大，边界不规则，周围见大片状水肿影，增强呈明显不均匀开环样强化，MRS示NAA减低，Cho升高，另左侧半卵圆中心见类圆形长T2信号，边界欠清，增强稍强化，脑沟裂增宽，脑室、脑池对称性扩大。中线结构无明显移位。MRA示：双侧颈内动脉、椎-基底动脉、大脑前动脉、大脑中动脉、大脑后动脉走行形态正常，显影良好，未见明显狭窄、中断。 双侧侧脑室旁多发异常信号，考虑炎性脱髓鞘假瘤伴颅内播散可能，占位待排，结合临床定性；老年性脑改变；头颅MRA未见明显异常。<br/>2024-01-04 手术标本活检检查：灰红碎组织一堆，大小约 <br/>1x0.9x0.3cm “左脑室三角区”送检少量神经胶质，伴出血，局部细胞丰富，考虑肿瘤性病变，建议进一步检查诊断日期：2023.12.26最终诊断：“左脑室三角区”结合HE图像及免疫组化结果，考虑胶质细胞瘤，WHO3级免疫组化结果：肿瘤细胞：GFAP(+),INI(核+),CK(-),Vim(+),S-100(+),Ki-67(+,约15%)建议做分子遗传学检测以进一步分级，并指导治疗。<br/>2024-01-25 肾功能:BUN 8.2mmol/L,CREA 25.1μmol/L,UA 83.62μmol/L；2024-01-25 电解质8项检测:K 3.76mmol/L,NA 134.00mmol/L,CL 99.00mmol/L,CA 2.21mmol/L,IRON 5.03μmol/L,MG 0.76mmol/L,P 0.66mmol/L,CO2 30.0mmol/L,2024-01-25 空腹血糖:GLU 10.24mmol/L,2024-01-25 血常规（五分类）:WBC 6.71*109/L,NE% 78.5%,RBC 3.21*1012/L,HGB 96g/L,HCT 30.7%,PLT 134.0*109/L,2024-01-23 B型钠尿肽（急诊）:NT-proBNP 241.00pg/ml。",
      "tentativeDiagnosis": "1.颅占位性病变：胶质瘤三级 2.高血压 3.糖尿病",
      "treatmentProcess": "入院后予以完善相关检查，于2023年12月21日在全麻下行“神经导航下左侧侧脑室三角区占位切除术”，术后予以脱水、抗感染、营养支持等治疗。",
      "mainDoctor": "1.颅占位性病变：胶质瘤三级 2.高血压 3.糖尿病",
      "patientComplaint": "头晕1月余，加重10余天",
      "inspectionMaterial": "",
      "clinicalDiagnosis": "",
      "medicalDetail": "",
      "surgicalFindings": "",
      "sendingPhysician": "",
      "comment": "",
      "ecg_source": null,
      "ecg_Status": null,
      "ecg_SubType": null,
      "image_equipmentType": "",
      "image_inspectionEquipment": "",
      "image_inspectionPart": "",
      "image_inspectionItem": "",
      "attachStr": null,
      "attach": {
        "imageExamAttachs": [],
        "ecgAttachs": [],
        "pathologyAttachs": [],
        "checkDiagnosticAttachs": [],
        "otherAttachs": [],
        "eusAttachs": []
      },
      "cosultationPurposeProfile": "405,",
      "consultationPurposeProfileStr": "寻求治疗方案;",
      "cosultationPurposeDescription": "进一步指导后续治疗。",
      "processAction": null,
      "approveProcess": "前质控",
      "approveStep": "server_quality_control",
      "approveStepUUID": "942b7886-ae5b-44d6-ac46-341f47b04699",
      "hospitalName": "上海交通大学医学院附属仁济医院",
      "approveProcessStr": "<span class='approveProcessStr' style='color:red'>退回</span>",
      "doctorPicUrl": null,
      "doctorName": null,
      "reportId": null,
      "advice": null,
      "suggest": null,
      "reportUrl": null,
      "reportUrlName": null,
      "reportDate": null,
      "signPicUrl": null,
      "pathologicalFindings": null,
      "attachInfo": {
        "appointHospitalOutpatientNumber": null,
        "appointHospitalAddress": null,
        "appointHospitalMoney": null,
        "appointHospitalAiagnosis": null,
        "appointHospitalEmergencyAiagnosis": null,
        "appointHospitalBedNumber": null,
        "appointHospitalPatientNumber": null,
        "appointHospitalRegisterIllnessId": null,
        "appointHospitalRegisterIllnessName": null,
        "appointHospitalRegisterBedLevelId": null,
        "appointHospitalRegisterBedLevelName": null,
        "appointHospitalRegisterTypeId": null,
        "appointHospitalRegisterTypeName": null,
        "appointSpecialistClinicDate": null,
        "outgoingSurgeryDate": null,
        "transferTreatment": null
      },
      "canSubmit": true,
      "reports": [],
      "attachInfos": [],
      "logs": [
        {
          "id": 6023,
          "stepName": "分诊",
          "userName": "贾芷莹",
          "userUUID": "e241c54b-d909-4368-9e75-dbeeca584509",
          "userHospitalId": 1,
          "userDepartmentName": null,
          "userSubDepartmentName": null,
          "date": "2024-01-30 14:27",
          "approveAction": "refuse",
          "approveActionStr": "退回",
          "msg": "分错"
        },
        {
          "id": 6022,
          "stepName": "会诊",
          "userName": "刘炜",
          "userUUID": "26e16b13-7459-4f6d-8968-9d08915d2586",
          "userHospitalId": 1,
          "userDepartmentName": "外科",
          "userSubDepartmentName": "泌尿科",
          "date": "2024-01-30 14:26",
          "approveAction": "refuse",
          "approveActionStr": "退回",
          "msg": "2"
        },
        {
          "id": 6021,
          "stepName": "分诊",
          "userName": "贾芷莹",
          "userUUID": "e241c54b-d909-4368-9e75-dbeeca584509",
          "userHospitalId": 1,
          "userDepartmentName": null,
          "userSubDepartmentName": null,
          "date": "2024-01-30 13:59",
          "approveAction": "agree",
          "approveActionStr": "通过",
          "msg": null
        },
        {
          "id": 6020,
          "stepName": "前质控",
          "userName": "贾芷莹",
          "userUUID": "e241c54b-d909-4368-9e75-dbeeca584509",
          "userHospitalId": 1,
          "userDepartmentName": null,
          "userSubDepartmentName": null,
          "date": "2024-01-30 13:58",
          "approveAction": "agree",
          "approveActionStr": "通过",
          "msg": null
        },
        {
          "id": 6019,
          "stepName": "待提交",
          "userName": "阜阳人民",
          "userUUID": "91f9f3c1-735c-400a-841e-7f8802ebcc48",
          "userHospitalId": 536,
          "userDepartmentName": null,
          "userSubDepartmentName": null,
          "date": "2024-01-30 13:48",
          "approveAction": "agree",
          "approveActionStr": "通过",
          "msg": null
        }
      ],
      "applyInstitutionStar": null,
      "serverInstitutionStar": null,
      "applyInstitutionComment": null,
      "serverInstitutionComment": null,
      "consultationEvaluationId": null,
      "applyQualityControlTime": null,
      "serverQualityControlTime": "2024-01-30 13:58",
      "diagnosisTime": "2024-01-30 14:27",
      "diagnosisCenterTime": null,
      "diagnosisOrganizationTime": null,
      "diagnosisDoctorEnsureTime": null,
      "diagnosisCenterEnsureTime": null,
      "consultationTime": "2024-01-30 14:26",
      "reportQualityControlTime": null,
      "publishTime": null,
      "applyControlName": "阜阳人民",
      "applyQualityControlName": null,
      "serverQualityControlName": "贾芷莹",
      "diagnosisName": "贾芷莹",
      "diagnosisCenterName": null,
      "diagnosisOrganizationName": null,
      "diagnosisDoctorEnsureName": null,
      "diagnosisCenterEnsureName": null,
      "consultationName": "刘炜",
      "reportQualityControlName": null,
      "publishName": null,
      "applyQualityControlRefuse": false,
      "serverQualityControlRefuse": false,
      "diagnosisRefuse": true,
      "diagnosisCenterRefuse": false,
      "diagnosisOrganizationRefuse": false,
      "diagnosisDoctorEnsureRefuse": false,
      "diagnosisCenterEnsureRefuse": false,
      "consultationRefuse": true,
      "reportQualityControlRefuse": false,
      "publishRefuse": false,
      "processMessage": null,
      "refuseReason": "分错",
      "refuseFlag": true,
      "applyInstitutionNameTag": "白玉兰",
      "serverHospAndDeptStr": null,
      "serverHospAndDeptAndDocStr": "上海交通大学医学院附属仁济医院 / 外科 / 泌尿科 / 刘炜",
      "hasPay": false,
      "schedulingStartTime": null,
      "schedulingEndTime": null,
      "reportStatus": "unPublish",
      "reportStatusStr": "未发布",
      "hasApplyQuality": false,
      "hasDiagnosis": true,
      "appyFormTemplateUrl": null,
      "informedConsentTemplateUrl": "",
      "appyFormUrl": null,
      "informedConsentUrl": null,
      "hasAllocation": null,
      "emergency": "否",
      "consultationScheduleRecordId": null,
      "platformProxy": false,
      "platformProxyStatus": null,
      "specialTimeZone": null,
      "realServerPrice": null,
      "counterpartSupportSpecial": null,
      "scheduling": null,
      "manage": true,
      "subDepartment": null,
      "immunohistochemistry": null,
      "finishVideo": false,
      "uuid": "2bf10715-31d4-41c6-bddd-baeabb6a34f4",
      "apply": false
    };
  },
});
</script>

<style scoped lang="scss">
.tab-card {
  margin: 12px;
  padding: 12px;
  background: #fff;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  row-gap: 14px;
  align-items: start;
}

.btn-box {
  background: white;
  padding: 8px 16px;
  display: flex;
  justify-content: space-between;
  column-gap: 6px;

  & > button {
    flex: 1;
  }
}
</style>
